﻿using System;

namespace NodeJS
{
    /// <summary>
    /// Can be implicit convert to int.
    /// </summary>
    public abstract class Timer
    {
        public static implicit operator int(Timer t)
        {
            return 0;
        }

        /// <summary>
        /// The opaque value returned by setTimeout and setInterval also has the method timer.unref() which will allow you to create a timer that is active but if it is the only item left in the event loop won't keep the program running.
        /// * If the timer is already unrefd calling unref again will have no effect.
        /// In the case of setTimeout when you unref you create a separate timer that will wakeup the event loop, creating too many of these may adversely effect event loop performance -- use wisely.
        /// </summary>
        public abstract void Unref();

        /// <summary>
        /// If you had previously unref()d a timer you can call ref() to explicitly request the timer hold the program open. If the timer is already refd calling ref again will have no effect.
        /// </summary>
        public abstract void Ref();
    }
}
